<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <script>
        var str = '长风破浪会有时';
        var ret = encodeURI(str);
        console.log(ret);
        var res = decodeURI(ret);
        console.log(res);
        // ----------------------------------
        var xhr = new XMLHttpRequest();
        xhr.open(
            'get',
            'http://www.liulongbin.top:3006/api/getbooks?uname=' + res
        );
        xhr.send();
        xhr.onreadystatechange = function() {};
    </script>
</body>

</html>